<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('money_books', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('user_id')->comment('创建者用户ID');
            $table->string('name', 50)->comment('账本名称');
            $table->string('description', 255)->nullable()->comment('账本描述');
            $table->boolean('is_default')->default(false)->comment('是否为默认账本');
            $table->timestamps();


            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('money_books');
    }
};
